package com.woniuxy.service.impl;

import java.lang.ref.WeakReference;
import java.util.concurrent.ThreadPoolExecutor;

/**
 * @Author: 马宇航
 * @Todo: TODO
 * @DateTime: 25/08/06/星期三 10:24
 * @Component: 成都蜗牛学苑
 **/
public class MyThreadPool {
    static ThreadLocal<Object> threadLocal = new ThreadLocal<>();
    public static void main(String[] args) {
        WeakReference<Object> haha = new WeakReference<>("强引用");
        new Thread(()->{
          threadLocal.set(new Object());
            try {
                System.gc();
                Thread.sleep(100);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            System.out.println(Thread.currentThread().getName()+":"+threadLocal.get());
        },"first线程").start();
        System.out.println(haha.get());
        System.gc();
        System.out.println(haha.get());
        new Thread(()->{
            threadLocal.set("second值");

            System.out.println(Thread.currentThread().getName()+":"+threadLocal.get());
        },"second线程").start();
        new Thread(()->{
            System.out.println(Thread.currentThread().getName()+":"+threadLocal.get());
        },"third线程").start();

    }
}
